package ru.pachkun.home.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;

public class FilmInfoPage extends Page {

	
	@FindBy(css="a[onclick*='./?go=delete']")
	private WebElement removeFilmLink;
	
	public FilmInfoPage(PageManager pages) {
		super(pages);
	}

	@Override
	public FilmInfoPage ensurePageLoaded() {
		super.ensurePageLoaded();
		wait.until(ExpectedConditions.presenceOfElementLocated(By.id("movie")));
		return this;
	}

	public InternalPage clickRemoveFilm() {
		removeFilmLink.click();
		wait.until(alertIsPresent()).accept();
		return pages.internalPage;
	}

}
